package com.example.dllo.my36kr.ui.activity.sonactivity;

import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;

import com.example.dllo.my36kr.R;
import com.example.dllo.my36kr.model.PeopleBean;
import com.example.dllo.my36kr.net.SingleVolley;
import com.example.dllo.my36kr.net.VolleyResult;
import com.example.dllo.my36kr.tools.PeopleUrl;
import com.example.dllo.my36kr.ui.activity.AbsBaseActivity;
import com.example.dllo.my36kr.ui.adapter.PeopleAdapter;
import com.google.gson.Gson;

import java.util.List;

/**
 * Created by CPC_272 on 16/8/23.
 */
public class PeopleActivity extends AbsBaseActivity implements VolleyResult {
    private ListView ls_people;
    private List<PeopleBean.DataBean.DataBean1> dataBean1List;
    private String peopleUrl = PeopleUrl.peopleUrl;
    private ImageView imageView;
    @Override
    protected int setLayout() {
        return R.layout.activity_people;
    }

    @Override
    protected void initView() {
        ls_people = byView(R.id.people_ls);
        imageView = byView(R.id.back_people);
    }

    @Override
    protected void initData() {
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        SingleVolley.getInstence(this).startRequest(peopleUrl,this);
    }

    @Override
    public void success(String str, int type) {

    }

    @Override
    public void success(String str) {
        Gson gson = new Gson();
        PeopleBean peopleBean = gson.fromJson(str,PeopleBean.class);
        PeopleBean.DataBean dataBean = peopleBean.getData();
        dataBean1List = dataBean.getData();
        PeopleAdapter peopleAdapter = new PeopleAdapter(this);
        peopleAdapter.setDataBean1List(dataBean1List);
        ls_people.setAdapter(peopleAdapter);
    }

    @Override
    public void failure() {

    }
}
